<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <title>title</title>
    <link rel="stylesheet" type="text/css" href="../css/api.css" />
    <style>
    html,
    body {
        width: 100%;
        height: 100%;
        margin: 0px;
        padding: 0px;
    }
    
    .main_dtl {
        width: 90%;
        margin: 30px auto 0px;
    }
    
    .main_dtl.active {
        display: block;
    }
    
    .mt_dtl {
        width: 100%;
        height: 80px;
        position: relative;
    }
    
    .tit_dtl {
        position: absolute;
        top: 0;
        font-size: 20px;
    }
    
    .time_dtl {
        font-size: 17px;
        position: absolute;
        top: 2px;
        left: 130px;
    }
    
    .info_dtl {
        position: absolute;
        font-size: 17px;
        left: 130px;
        top: 34px;
        color: #a9a9a9;
    }
    
    .per_dtl {
        height: 80px;
        width: 100%;
        position: relative;
    }
    
    .perTit_dtl {
        position: absolute;
        top: 0;
        font-size: 20px;
    }
    
    .perName_dtl {
        font-size: 17px;
        position: absolute;
        top: 0;
        left: 130px;
    }
    
    .perInfo_dtl {
        position: absolute;
        margin-left: 28px;
        font-size: 17px;
        left: 200px;
        top: 0;
    }
    
    .name_dtl {
        height: 80px;
        width: 100%;
        position: relative;
    }
    
    .nameTit_dtl {
        position: absolute;
        top: 0;
        font-size: 20px;
    }
    
    .nameInfo_dtl {
        font-size: 17px;
        position: absolute;
        top: 0;
        left: 130px;
    }
    
    .desc_dtl {
        height: 150px;
        width: 100%;
        position: relative;
    }
    
    .descTit_dtl {
        position: absolute;
        top: 0;
        font-size: 20px;
    }
    
    .descInfo_dtl {
        font-size: 17px;
        position: absolute;
        top: 0;
        left: 130px;
    }
    
    .footer_dtl {
        position: absolute;
        background-color: #8c5ac0;
        width: 90%;
        left: 50%;
        margin-left: -45%;
        height: 57px;
        line-height: 57px;
        text-align: center;
        border-radius: 5px;
        bottom: 40px;
        color: #fff;
        font-size: 20px;
    }
    
    .tit {
        height: 50px;
        line-height: 50px;
        width: 100%;
        font-size: 17px;
        text-align: center;
        font-weight: 600;
        border-bottom: 1px solid #e7e6e7;
    }
    
    .left {
        position: absolute;
        width: 50px;
        height: 40px;
        background-image: url(../image/left.png);
        background-repeat: no-repeat;
        background-size: 22px 22px;
        background-position: center;
    }
    
    #header {
        background-color: #8c5ac0;
        color: #fff;
    }
    </style>
</head>

<body>
    <header id="header">
        <div class="left" tapmode onclick="api.closeWin();"></div>
        <div class="tit" id="tit"></div>
    </header>
    <div class="main_dtl ">
        <div class="mt_dtl">
            <div class="tit_dtl">课程时间</div>
            <div class="time_dtl"></div>
        </div>
        <div class="per_dtl">
            <div class="perTit_dtl">讲师</div>
            <div class="perName_dtl"></div>
        </div>
        <div class="name_dtl">
            <div class="nameTit_dtl">主题</div>
            <div class="nameInfo_dtl"></div>
        </div>
        <div class="desc_dtl">
            <div class="descTit_dtl">简介</div>
            <div class="descInfo_dtl"></div>
        </div>
        <div class="footer_dtl" tapmode="" onclick="openDetail()">
            进入视频
        </div>
    </div>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript">
var tencentPlayer;

apiready = function() {
    videoId = api.pageParam.videoId;
    tit = api.pageParam.title;
    $api.html($api.byId('tit'), tit);
    fnInitEventListener();
    listAjax();
    fnOpenNewsFrm();
};
// 详情页数据请求
function listAjax() {
    data = {
        fields: {},
        where: {
            id: videoId
        },
        include: ['typePointer'],
        skip: 0,
        limit: 1
    };
    data = JSON.stringify(data);
    api.ajax({
        url: 'http://d.apicloud.com/mcm/api/video?filter=' + data,
        method: 'get',
        headers: {
            "X-APICloud-AppId": "A6922938320433",
            "X-APICloud-AppKey": "bf08237883477a7a6b88b41b0c55ceb7f6839a84.1477487496656"
        },
    }, function(ret, err) {
        if (ret) {
            Json = ret;
            listInfo()
        } else {
            alert(JSON.stringify(err));
        }
    });
}
// 详情页数据处理
function listInfo() {
    var time = $api.dom(".time_dtl");
    var teacher = $api.dom(".perName_dtl");
    var name = $api.dom(".nameInfo_dtl");
    var description = $api.dom(".descInfo_dtl");
    $api.html(time, Json[0].courseTime);
    $api.html(teacher, Json[0].teacher);
    $api.html(name, Json[0].name);
    $api.html(description, Json[0].description);
}

function fnOpenNewsFrm() {
    var header = $api.byId('header');
    $api.fixIos7Bar(header);
    $api.fixStatusBar(header);
    var header_h = $api.offset(header).h;
    var frm_h = api.winHeight - header_h;
};

function fnInitEventListener() {
    api.addEventListener({
        name: 'keyback'
    }, function(ret, err) {
        api.closeWin();
    });
}

// 点击footer打开视频
function openDetail() {
    tencentPlayer = api.require('tencentPlayer');
    tencentPlayer.open({
        rect: {
            x: 0,
            y: 70,
            w: api.winWidth,
            h: 300
        },
        fixedOn: api.frameName,
        fixed: true
    }, function(ret, err) {
        if (ret.status) {} else {}
    });
    tencentPlayer.play({
        path: Json[0].url
    });
}

</script>

</html>
